package com.stx.House.DynamicForJdk;

import com.stx.House.staticproxy.IHouseOwner;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class HouseAgentByDynamicForJdk implements InvocationHandler {
    private IHouseOwner owner;

    public HouseAgentByDynamicForJdk(IHouseOwner owner) {
        this.owner = owner;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("中介替购房者完成筛选房屋...最终选定了一间房。");
        Object result = method.invoke(owner, args);
        System.out.println("中介替购房者完成与房主签订的售房合同。");
        return result;
    }
}
